<template>
  <div>
    <Background pageType="2" />
    <div class="body">
      <div class="g-con tab">
        <span
          :class="{ avtive: pageType == 0 }"
          @click="pageType = 0"
          >{{ t('organizationStructure.tab1') }}</span
        >
        <span
          :class="{ avtive: pageType == 1 }"
          @click="pageType = 1"
          >{{ t('organizationStructure.tab2') }}</span
        >
        <span
          :class="{ avtive: pageType == 2 }"
          @click="pageType = 2"
          >{{ t('organizationStructure.tab3') }}</span
        >
      </div>
      <Information
        v-if="pageType == '0'"
        :pageInfo="enterpriseInfo"
      />
      <OStructure v-if="pageType == '1'" />
      <PublishAnArticle v-if="pageType == '2'" />
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import Information from './cmp/Information.vue'
import OStructure from './cmp/OStructure.vue'
import PublishAnArticle from './cmp/PublishAnArticle.vue'
import Background from '@/components/Background.vue'
import { useI18n } from 'vue-i18n'
import { getEnterpriseInfo } from '@/service/organizationStructure'

const { t, locale } = useI18n()

const router = useRouter()
const route = useRoute()

const pageType = ref(route.query.tab || 0)
const enterpriseInfo = ref({})

onMounted(async () => {
  let id = JSON.parse(localStorage.getItem('login')).userInfo.enterpriseId
  await getEnterpriseInfo(id).then((res) => {
    enterpriseInfo.value = res.data
  })
})
</script>
<style lang="scss" scoped>
.tab {
  height: 42px;
  line-height: 42px;
  font-size: 14px;
  display: flex;

  span {
    background: rgba(235, 212, 212, 0.8);
    min-width: 120px;
    text-align: center;
    max-width: 280px;
    margin-right: 1px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    padding: 0 20px;
    cursor: pointer;
  }

  .avtive {
    color: #ca2a02;
    background: white;
  }
}

.body {
  width: 100%;
  background: #f9f9f9;
  padding-top: 28px;
  padding-bottom: 53px;
  margin-bottom: -76px;
}
.footer {
  margin-top: 0 !important;
}
</style>
